<div class="db_left bl">
    <?php $this->load->view('medical/object/side_block'); ?>
</div>
    <div class="db_right bl">
        <div class="std_header auto_height">
            <div class="left">
                <strong>Thông tin bộ phận cơ thể</strong>
            </div>
        </div>
        <div id="parts_management">
            <form id="frm_parts_edit" enctype="multipart/form-data" method="POST" action="<?php echo $save_action; ?>">
                <?php $this->load->view('medical/parts/message'); ?>
                <input id="entity_id" type="hidden" name="id" value="<?php echo isset($parts->id) ? $parts->id : '' ; ?>" />
                <div class="clearfix auto_height mb_10 mt_10">
                    <button class="gray_btn " type="button" onclick="window.location = '<?php echo site_url('admin/medical/parts/index', true); ?>'"><span>Về danh sách</span></button>
                    <button class="gray_btn" type="submit" ><span>Lưu lại</span></button>
                    <button class="gray_btn" type="reset"><span>Nhập lại</span></button>
                    <?php if (isset($parts->id) && $has_privilege_delete) :?>
                    <button class="gray_btn delete_btn" type="button" action="<?php echo site_url('admin/medical/parts/delete/id/' . $parts->id, true); ?>" message="Bạn muốn xóa đối tượng này?" onclick="btn_util.active_delete(this)"><span>Xóa đối tượng</span></button>
                    <?php endif; ?>
                </div>
                <div class="form_block">
                    <div class="block_header">
                        Thông tin cơ bản
                    </div>
                    <div class="block_content">
                        <table cellpadding="0px" cellspacing="0px">
                            <tr>
                                <td class="frm_label">Tên bộ phận cơ thể(*)</td>
                                <td class="frm_field">
                                    <input type="text" class="std_input required" name="data[name]" title="Tên bộ phận cơ thể không được để trống" value="<?php echo get_field($parts, 'name'); ?>" />
                                </td>
                            </tr>
                            <tr>
                                <td class="frm_label">Bí danh</td>
                                <td class="frm_field">
                                    <input type="text" class="std_input" title="Bí danh" name="data[alter_name]"  value="<?php echo get_field($parts, 'alter_name'); ?>" />
                                </td>
                            </tr>
                            <tr>
                                <td class="frm_label">Bộ phận cha</td>
                                <td class="frm_field">
                                    <select name="data[parent_id]" id="parent_id_parts">

                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td class="frm_label">Ảnh minh họa</td>
                                <td class="frm_field">
                                    <?php $image = get_field($parts, 'image'); ?>
                                    <?php if (!empty($image)) :?>
                                    <a target="_blank" href="<?php echo render_src($image); ?>"><img src="<?php echo render_src($image); ?>" width="40px" style="vertical-align: middle; border: 2px solid #bbb" /></a>
                                    <?php endif; ?>
                                    <input type="file" name="data_image" />
                                    &nbsp;
                                    <input onclick="return admin_medical_parts.show_img_path(this.checked)" style="top: 2px; position: relative" type="checkbox" name="set_img_url" id="set_img_url" value="1" />
                                    <label for="set_img_url">Chọn đường dẫn ảnh</label>
                                    <div class="clearfix mt_10" id="wp_img_path" style="display: none">
                                        <input name="img_path" type="text" class="std_input" value="<?php echo $image; ?>" />
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td class="frm_label">Mô tả ngắn</td>
                                <td class="frm_field">
                                    <textarea rows="" cols="" name="data[description]" title="Mô tả ngắn"><?php echo get_field($parts, 'description'); ?></textarea>
                                </td>
                            </tr>
                            <tr>
                                <td class="frm_label">Hiển thị</td>
                                <td class="frm_field">
                                    <select class="std_input" name="data[is_hidden]">
                                        <option value="1" <?php if (isset($parts->is_hidden) && $parts->is_hidden == 1) :?> selected="selected" <?php endif; ?>>Hiện</option>
                                        <option value="2" <?php if (isset($parts->is_hidden) && $parts->is_hidden == 2) :?> selected="selected" <?php endif; ?>>Ẩn</option>
                                    </select>
                                </td>
                            </tr>

                        </table>
                    </div>
                </div>
                <div class="form_block">
                    <div class="block_header">
                        Thông tin khác
                    </div>
                    <div class="block_content">
                        <table cellpadding="0px" cellspacing="0px">
                            <tr>
                                <td class="frm_label">Thuộc khoa</td>
                                <td class="frm_field" id="area_department">

                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
                <div class="form_block">
                    <div class="block_header">
                        Thông tin SEO
                    </div>
                    <div class="block_content">
                        <table cellpadding="0px" cellspacing="0px">
                            <tr>
                                <td class="frm_label">Tiêu đề(*)</td>
                                <td class="frm_field">
                                    <input type="text" class="std_input" name="data[meta_title]" value="<?php echo get_field($parts, 'meta_title'); ?>" />
                                </td>
                            </tr>
                            <tr>
                                <td class="frm_label">Từ khóa(*)</td>
                                <td class="frm_field">
                                    <input type="text" class="std_input" name="data[meta_keywords]" value="<?php echo get_field($parts, 'meta_keywords'); ?>" />
                                </td>
                            </tr>
                            <tr>
                                <td class="frm_label">Mô tả(*)</td>
                                <td class="frm_field">
                                    <textarea class="std_editor"  name="data[meta_description]"><?php echo get_field($parts, 'meta_description'); ?></textarea>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
                <div class="clearfix auto_height mb_10">
                    <button class="gray_btn " type="button" onclick="window.location = '<?php echo site_url('admin/medical/parts/index', true); ?>'"><span>Về danh sách</span></button>
                    <button class="gray_btn" type="submit" ><span>Lưu lại</span></button>
                    <button class="gray_btn" type="reset"><span>Nhập lại</span></button>
                    <?php if (isset($parts->id) && $has_privilege_delete) :?>
                    <button class="gray_btn delete_btn" type="button" action="<?php echo site_url('admin/medical/parts/delete/id/' . $parts->id, true); ?>" message="Bạn muốn xóa đối tượng này?" onclick="btn_util.active_delete(this)"><span>Xóa đối tượng</span></button>
                    <?php endif; ?>
                </div>
            </form>
        </div>
    </div>


<div class="clearfix"></div>
<script type="text/javascript" src="<?php echo BASE_URL; ?>js/admin/medical/object/function.js"></script>
<script type="text/javascript">
    var allDep = <?php echo $list_department;?>;//lấy hết các khoa
    var allParts = <?php echo $list_parts;?>;//lấy hết bộ phận cơ thẻ
    var parentParts = '<?php echo get_field($parts, 'parent_id'); ?>';
    var departIds = <?php echo $dep_ids; ?>;//array id của khoa

    $("#frm_parts_edit").validate({
        errorLabelContainer: $("#form_error")
    });

    function create_new(){
        $('#active_tab_edit a').trigger('click');
        $("#entity_id").val(0);
        $("#frm_parts_edit input[type='text']").val("");
        $(".std_editor").text("");
    }

    admin_medical_parts.showChkDep(allDep, 'area_department', departIds);
    admin_medical_parts.showOptParts(allParts, 'parent_id_parts', parentParts);
</script>
